#include"process.h"
#include<string.h>
#include<unistd.h>
#include<stdlib.h>

#define SIZE 101
#define MAX_RATR 100
#define STYLE '#'
#define STIME 1000*200

const char *str="|/-\\";

void process()
{
    //version1
    int rate=0;
    char bar[SIZE];
    memset(bar,'\0',sizeof(bar));
    int num=strlen(str);

    while(rate<=MAX_RATR)
    {
        printf("\033[%d;%dm[%-100s]\033[0m\033[40;%dm[%d%%]\033[0m\033[40;%dm[%c]\033[0m\r",
        rand()%10+40,rand()%10+30,bar, rand()%10+30,rate,rand()%10+30, str[rate%num]);
        //printf("[%-100s][%d%%][%c]\r",bar,rate,str[rate%num]);
        fflush(stdout);
        usleep(STIME);
        bar[rate++]=STYLE;
    }
    printf("\n");
}
